package solitaire.gui;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;

import solitaire.extras.DrawObject;

public class MyImage extends DrawObject
{
    private BufferedImage m_imgImage;

    public MyImage(double dX, double dY, BufferedImage image)
    {
        m_dStartX = dX;
        m_dStartY = dY;
        this.m_imgImage = image;
    }

    public void drawObject(Graphics g)
    {
        Graphics2D g2 = (Graphics2D)g;
        g2.drawRenderedImage( m_imgImage, 
        AffineTransform.getTranslateInstance( 
        		m_dStartX - m_imgImage.getWidth()/2 , 
        		m_dStartY - m_imgImage.getHeight()/2 ) );
    }

    public boolean contains(Point2D point)
    {
        return point.getX() >= (m_dStartX - m_imgImage.getWidth()/2) && 
        	point.getX() <= (m_dStartX + m_imgImage.getWidth()/2) &&
        	point.getY() >= (m_dStartY - m_imgImage.getHeight()/2) && 
        	point.getY() <= (m_dStartY + m_imgImage.getHeight()/2);
    }

    public void setLocation(double dX, double dY)
    {
        m_dStartX = dX;
        m_dStartY = dY;
    }
}


